package com.base.cloud.web.controller;

import com.base.cloud.web.service.TestService;
import com.base.common.spi.entitys.base.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

@Slf4j
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @Autowired
    TestService testService;

    @RequestMapping(value = "/echo")
    public JsonResult<String> echo(HttpServletRequest request, String msg) {
        HttpSession session = request.getSession();
        session.setAttribute("echo", msg);
        log.info("调用了web层echo方法，参数msg={}, session={}", msg, session.getId());
        return testService.echo(msg);
    }
}
